﻿using Infragistics.Composite.Wpf.Docking;
using Infragistics.Composite.Wpf.Proxies.Docking;
using Infragistics.Windows.DockManager;
using Microsoft.Practices.Composite.Regions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Infragistics.Composite.Wpf.Tests.Docking
{
    /// <summary>
    /// Unit tests for the XamDockManagerRegionAdapter class.
    /// </summary>
    [TestClass]
    public class XamDockManagerRegionAdapterTests
    {
        #region Boilerplate Code

        public XamDockManagerRegionAdapterTests()
        {
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        #endregion // Boilerplate Code

        [TestMethod]
        public void TestAdapt()
        {
            XamDockManagerRegionAdapterSubclass target = new XamDockManagerRegionAdapterSubclass();

            XamDockManagerRegion region = new XamDockManagerRegion();
            XamDockManager dockManager = new XamDockManager();
            XamDockManagerProxy dockManagerProxy = new XamDockManagerProxy(dockManager);

            target.AdaptTest(region, dockManager);

            Assert.IsNotNull(region.DockManagerProxy, "DockManager was not set");
        }

        [TestMethod]
        public void TestCreateRegion()
        {
            XamDockManagerRegionAdapterSubclass target = new XamDockManagerRegionAdapterSubclass();

            IRegion region = target.CreateRegionTest();

            Assert.IsTrue(region is XamDockManagerRegion, "Did not create XamDockManagerRegion");
        }
    }

    class XamDockManagerRegionAdapterSubclass : XamDockManagerRegionAdapter
    {
        public void AdaptTest(XamDockManagerRegion region, XamDockManager dockManager)
        {
            this.Adapt(region, dockManager);
        }

        public IRegion CreateRegionTest()
        {
            return this.CreateRegion();
        }
    }
}
